// 资产 - 亚数币日志页
// import { isEmpty } from 'lodash'
import * as types from '@/store/mutation-types'
import api from '@/tools/api.js'
// import promise from '@/tools/promise'
// import { SUCCESS_STATUS } from '@/config/status'
const state = {
  list: [],
  pageData: {
    total: 1,
    per_page: 15,
    current_page: 1,
    last_page: 1
  }
}

// mutations
const mutations = {
  [types.CURRENCY_LOG_LIST] (state, payload) {
    state.list = payload.data
    state.pageData.total = Number(payload.total)
    state.pageData.per_page = Number(payload.per_page)
    state.pageData.current_page = Number(payload.current_page)
    state.pageData.last_page = Number(payload.last_page)
  }
}

// actions
const actions = {
  // 获取资金日志列表
  async getCurrencyLogList ({ commit }, payload) {
    let config = {loading: true, loadingText: '正在获取亚数币日志列表'}
    let url = ''
    if (payload.operateType === 'operation') {
      url = 'serverfund/currency/CurrencyOptionLog/list'
    } else if (payload.operateType === 'freeze') {
      url = 'serverfund/currency/CurrencyFreezeLog/list'
    } else if (payload.operateType === 'unfreeze') {
      url = 'serverfund/currency/CurrencyUnfreezeLog/list'
    }
    let getRes = await api(url, payload, config)
    commit(types.CURRENCY_LOG_LIST, getRes.res)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
